
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<jsp:directive.page import="java.sql.*"/>
<jsp:directive.page import="Connectivity.ConnectionManager"/>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String Activity = request.getParameter("Activity")!=null?request.getParameter("Activity"):"2";
 
String status = request.getParameter("status")!=null?request.getParameter("status"):"";
String calltype = request.getParameter("calltype")!=null?request.getParameter("calltype"):"";
String fdate = request.getParameter("fdate")!=null?request.getParameter("fdate"):"";
String tdate = request.getParameter("tdate")!=null?request.getParameter("tdate"):"";


Connection con=ConnectionManager.getConnection();

System.out.println("calltype"+calltype);
String Headinglabel="CALL REPORT";
if(calltype.equalsIgnoreCase("ASSIGNED"))
{Headinglabel="CALL ASSIGNED";}
if(calltype.equalsIgnoreCase("CLOSED"))
{Headinglabel="CALL CLOSED";}
if(calltype.equalsIgnoreCase("MTAKEN"))
{Headinglabel="MATERIAL TAKEN";}
if(calltype.equalsIgnoreCase("MGIVEN"))
{Headinglabel="MATERIAL GIVEN";}
if(calltype.equalsIgnoreCase("PFP"))
{Headinglabel="PENDING FOR PARTS";}
if(calltype.equalsIgnoreCase("0$all"))
{calltype="ALL";}



%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
 
    
    <title> CALL STATUS </title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<script type="text/javascript" src="/other/data.js"></script>
    
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>

  
 <script>
 
function insertParam(key, value) 
{    
	key = escape(key); value = escape(value);
    var kvp = document.location.search.substr(1).split('&');
 	if (kvp == '') 
 	{
 	document.location.search = '?' + key + '=' + value;
 	}
 	else 
 	{
 	var i = kvp.length; var x; while (i--) 
 	{
 	  x = kvp[i].split('='); 
 	if (x[0] == key) 
  {
   x[1] = value;
   kvp[i] = x.join('=');
   break;
  }
  }
  if (i < 0) 
  { kvp[kvp.length] = [key, value].join('='); }
        //this will reload the page, it's likely better to store this until finished 
    document.location.search = kvp.join('&');         
  }
} 
function callDegree(obj)
{
		
		 if(obj.name=='callstype')
		 {insertParam((obj.name),(obj.value));}
		
	
 
			//document.callentry.action = "";
			//document.callentry.submit();
} 
</script>
  
  <body>
  
<table border=0 bordercolor=black width=100%  cellspacing=0>
<tr><td>
<table  border=1 bordercolor=black width=100% cellspacing=0 height=120px>
			<tr >
			 <td align=center height=120px width=90%><font size=5><b><%=(session.getAttribute("firm_name"))%></b></font></td>
			 <td align=right height=120px  width=10%><img src="<%=basePath%>images\Company.jpg" height=119 width=109></td> 
			 </tr>
			
    <form name=callassign action=temp.jsp method=get>
    <%
    
  String role_id1=""+(session.getAttribute("role_id")); 
 String calltypestaus="CLOSED";
  if(role_id1.equals("1"))
  {
    } %>  
	 <tr><td colspan=10>
     <table width=100% border=1 bordercolor=black bordersize=thin cellspacing=0>
	   
    <tr><td align=center   colspan=10><font size=4 color=Blue> <%=Headinglabel%> </font></td></tr>
   
     </td></tr>
     
     
     
     
     
     <tr>
     <td align=center  rowspan=2 nowrap="nowrap"><font size=2 color="light pink"><b>Sr.No.</b></font></td>
     <td rowspan=2 nowrap="nowrap" ><font size=2 color="light pink"><b> DATE</b></font></td>
     <td rowspan=2 nowrap="nowrap" ><font size=2 color="light pink"><b>COMPLAINT ID</b></font></td>
     <td rowspan=2 nowrap="nowrap"><font size=2 color="light pink"><b>CUSTOMER NAME</b></font></td>
     <td rowspan=2 nowrap="nowrap"><font size=2 color="light pink"><b>BRANCH</b></font></td>
     <td rowspan=2 nowrap="nowrap"><font size=2 color="light pink"><b>NATURE OF FAULT</b></font></td>
     <td  rowspan=2 nowrap="nowrap"><font size=2 color="light pink"><b>ITEM</b></font></td>
     <% if(calltype.equals("CLOSED"))
  { %>
    <td  rowspan=2><font size=2 color="BLACK"><font size=2 color="light pink"><b>ACTION TAKEN</b></font></td>           
  <%}%>
     <td  rowspan=2 nowrap="nowrap"><font size=2 color="light pink"><b>EMPLOYEE</b></font></td>
      <%
  if(calltype.equals("ALL"))
  { %>
    <td  rowspan=2><font size=2 color="BLACK"><font size=2 color="light pink"><b>CALL STATUS</b></font></td>           
  <%}
    else if(calltype.equals("PFP") || calltype.equals("ASSIGNED"))
  { %>
    <td  rowspan=2><font size=2 color="BLACK"><font size=2 color="light pink"><b>PENDING FROM</b></font></td>           
  <%}
  
   %></tr> 
      
     <%
     boolean flag=false;
     int count=0;
     String emp_id="",call_details="",item="",call_status="";
     String compalint_id="-",customer_name="-",area="-",cust_type="-",callentry_id="",assigndate="",employee_name="";
    try
    {
   	CallableStatement cstmt = null;
		ResultSet calldisplayrs = null;
 if(calltype.equalsIgnoreCase("PFP")){calltype="PFPE";}
			cstmt = con.prepareCall("{?=call fun_retrieve_call_report(?,?,?,?)}");
			cstmt.registerOutParameter(1, Types.OTHER);
			cstmt.setString(2,calltype);
    		cstmt.setString(3,fdate);
			cstmt.setString(4,tdate);
			cstmt.setObject(5,calldisplayrs);
			
			con.setAutoCommit(false);
			cstmt.execute();
			
			calldisplayrs =(ResultSet) cstmt.getObject(1);	
 	
 	
 	
 	
 	String callduration="",actiontaken="";
 	//String calldisplay="select function fun_retrieve_callentry("+calltypestaus+")";
    // PreparedStatement calldisplayprs=con.prepareStatement(calldisplay);
     //ResultSet calldisplayrs=calldisplayprs.executeQuery();
    while(calldisplayrs.next())
     {
     flag=true;count++;
     assigndate=calldisplayrs.getString(2);
     compalint_id=calldisplayrs.getString(3);
     callentry_id= calldisplayrs.getString(1);
     customer_name=calldisplayrs.getString(4);
     area=calldisplayrs.getString(5);
     cust_type=calldisplayrs.getString(6);
     call_details=calldisplayrs.getString(7);
     item=calldisplayrs.getString(8);
     employee_name=calldisplayrs.getString(9);
     call_status=calldisplayrs.getString(10);
   	 if(calltype.equals("PFPE") || calltype.equals("ASSIGNED"))
  	{callduration=calldisplayrs.getString(11);}
  	if(calltype.equals("CLOSED"))
  	{actiontaken=calldisplayrs.getString(11);}
   %>
   <tr></tr>
   <tr>
        
    <td  rowspan=2><font size=2 ><%=count%></font></td>
    <td  rowspan=2 nowrap="nowrap"><font size=2 color="BLACK"><%=assigndate %></font></td>
    <td  rowspan=2 ><font size=2 color="BLACK"><%=compalint_id %></font></td>
    <td  rowspan=2><font size=2 color="BLACK"><%=customer_name.toUpperCase() %></font></td>
    <td  rowspan=2><font size=2 color="BLACK"><%=area %></font></td>
    <td  rowspan=2><font size=2 color="BLACK"><%=call_details.toUpperCase()%></font></td>      
    <td  rowspan=2><font size=2 color="BLACK"><%=item.toUpperCase() %></font></td>
    <%if(calltype.equals("CLOSED") ) 
  { %>
    <td  rowspan=2><font size=2 color="BLACK"><%=actiontaken.toUpperCase()%></font></td>           
  <%}%>
    <td  rowspan=2 ><font size=2 color="BLACK"><%=employee_name.toUpperCase()%></font></td>           
  <%
  if(calltype.equals("ALL"))
  { %>
    <td  rowspan=2><font size=2 color="BLACK"><%=call_status.toUpperCase()%></font></td>           
  <%}
  else if(calltype.equals("PFPE") || calltype.equals("ASSIGNED"))
  { %>
    <td  rowspan=2><font size=2 color="BLACK"><%=callduration%></font></td>           
  <%}
  
  %>
  
   </tr>
   
   
    
   <%} %>
   
 </table>
 </td></tr>
  <!--  <a href="paging.jsp">paging</a>
    -->
   </form>
   </table>
   <% 
    }
    catch(Exception e)
    {e.printStackTrace();}
    finally
    {
    con.close();
    } 
      %>
  </body>
</html>
